import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from "@nestjs/common";
import { MenuService } from "./menu.service";
import { CreateMenuDto } from "./dto/create-menu.dto";
import { UpdateMenuDto } from "./dto/update-menu.dto";
import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger";
import { FindAllMenuDto } from "./dto/find-all-menu.dto";

@Controller("system/menu")
@ApiTags("菜单权限")
@ApiBearerAuth()
export class MenuController {
    constructor(private readonly menuService: MenuService) {
    }
    
    @Post()
    @ApiOperation({ summary: "创建菜单" })
    create(@Body() createMenuDto: CreateMenuDto) {
        return this.menuService.create(createMenuDto);
    }
    
    @Get()
    @ApiOperation({ summary: "菜单列表" })
    findAll(@Query() findAllMenuDto: FindAllMenuDto) {
        return this.menuService.findAll(findAllMenuDto);
    }
    
    @Get("findAllTree")
    @ApiOperation({ summary: "菜单列表树" })
    findAllTree() {
        return this.menuService.findAllTree();
    }
    
    @Get(":id")
    findOne(@Param("id") id: string) {
        return this.menuService.findOne(+id);
    }
    
    @Patch(":id")
    @ApiOperation({ summary: "修改菜单" })
    update(@Param("id") id: string, @Body() updateMenuDto: UpdateMenuDto) {
        return this.menuService.update(+id, updateMenuDto);
    }
    
    @Delete(":id")
    @ApiOperation({ summary: "删除菜单" })
    remove(@Param("id") id: string) {
        return this.menuService.remove(+id);
    }
}
